package com.nbsaas.boot.data.rest.convert;

import com.nbsaas.boot.data.data.entity.QueryReport;
import com.nbsaas.boot.data.api.domain.response.QueryReportResponse;

import com.nbsaas.boot.utils.BeanDataUtils;
import com.nbsaas.boot.rest.api.Converter;
import java.util.HashMap;
import java.util.Map;
/**
* -实体对象转化成响应对象
*/

public class QueryReportResponseConvert  implements Converter<QueryReportResponse,QueryReport> {

    @Override
    public QueryReportResponse convert(QueryReport source) {
        QueryReportResponse  result = new  QueryReportResponse();
        BeanDataUtils.copyProperties(source, result);

                    try {
                        if(source.getCreator()!=null){
                            result.setCreatorName(source.getCreator().getName());
                        }
                    } catch (Exception ignored) { }

                    if(source.getType()!=null){
                    Map<Integer,String> TypeMap=new HashMap<>();
                        TypeMap.put(1,"公共查询");
                        TypeMap.put(2,"私有查询");
                    String label=  TypeMap.get(source.getType());
                    result.setTypeName(label);
                    }
                    result.setType(source.getType());
                    if(source.getExecType()!=null){
                    Map<Integer,String> ExecTypeMap=new HashMap<>();
                        ExecTypeMap.put(1,"执行存储过程");
                        ExecTypeMap.put(2,"不执行存储过程");
                    String label=  ExecTypeMap.get(source.getExecType());
                    result.setExecTypeName(label);
                    }
                    result.setExecType(source.getExecType());
                    if(source.getCreator()!=null){
                        result.setCreator(source.getCreator().getId());
                    }
                    if(source.getDisplayType()!=null){
                    Map<Integer,String> DisplayTypeMap=new HashMap<>();
                        DisplayTypeMap.put(1,"表格");
                        DisplayTypeMap.put(2,"分页");
                    String label=  DisplayTypeMap.get(source.getDisplayType());
                    result.setDisplayTypeName(label);
                    }
                    result.setDisplayType(source.getDisplayType());
        return result;
    }

}

